# 优惠券（本次无限使用）：奖池（随机抽取一张  ["烤鸡腿",5]6张3折  ["烤火烈鸟腿",5000]10张一折） 系统开始就随机抽取一张优惠券
# 附加1、优惠券只能使用一次
# 附加2、满减返现 300（花出去的钱） 返现10
# 附加3、日期双十一 618 全场8折 先全场8折 在优惠券
import datetime
import random


# 定义商品列表
shop=[
    ["烤鸡腿",5],
    ["烤鸭腿",9],
    ["烤鹅腿",20],
    ["烤鱼腿",100],
    ["烤火烈鸟腿",5000],
    ["烤猪蹄",15],
    ["烤鸭脖",13],
    ["烤牛腿",80],
    ["扬州炒饭",13],
    ["山东炒饭",12],
    ["煲仔饭",25],
    ["烤馕",5],
    ["乌冬面",17]
]

# 定义折扣
z = [
    [6,3],
    [7,6],
    [8,8],
    [0,7],
    [0,5],
    [8,6],
    [9,6],
    [0,6],
    [5,6],
    [6,6],
    [4,6],
    [2,6],
    [1,6]
]

# 定义购物车
mycar = []

# 初始金额
money = 1000

# 定义类
# 打折类
def Sale(money):
    # 判断商品是否存在
    if shop[num] in shop:
        # 判断余额
        if money >= shop[num][1]:
            # 添加进购物车
            mycar.append([shop[num][0],shop[num][1]*z[number][1]/10])
            money = money - shop[num][1]*z[number][1]/10
            return money
        else:
            print("余额不足,无法购买")
    else:
        print("对不起，您选择的商品不存在，请重新选择！")

# 普通类
def Sale1(money):
    # 判断商品是否存在
    if shop[num] in shop:
        # 判断余额
        if money >= shop[num][1]:
            # 添加进购物车
            mycar.append([shop[num][0],shop[num][1]])
            money = money - shop[num][1]
        else:
            print("余额不足,无法购买")
    else:
        print("对不起，您选择的商品不存在，请重新选择！")

# 主体
number = random.randint(0, 12)
while True:
    print("欢迎来到苏格兰小烧烤店")
    print("现在是%s,店内已消毒"%(datetime.datetime.now()))
    print("这是菜单供您挑选 :")
    for key,value in enumerate(shop):
        print(key,value)
    z[number][0] = z[number][0] - 1
    if z[number][0] >= 0:
        print("恭喜您抽到%s%s折优惠券一张！"%(shop[number][0],z[number][1]))
        num = input("请输入您要购买的菜品编号 :")
        if num.isdigit():
            num = int(num)
            Sale(money)
            chose = input("是否继续购买？Y/N")
            if chose == "Y" or chose == "y":
                continue
            elif chose == "N" or chose == "n":
                print("这是您的小票，请拿好！")
                for i in mycar:
                    print(i)
                print("余额还有%s"%(money))
                print("欢迎下次光临！")
                break
        else:
            print("选择菜品编号错误，请重新输入！")
    elif z[number][0] < 0:
        print("很遗憾,奖池%s优惠券已抽完,本次购买不享受折扣!"%(shop[number][0]))
        num = input("请输入您要购买的菜品编号 :")
        if num.isdigit():
            num = int(num)
            money = Sale1(money)
            chose = input("是否继续购买？Y/N")
            if chose == "Y" or chose == "y":
                continue
            elif chose == "N" or chose == "n":
                print("这是您的小票，请拿好！")
                for i in mycar:
                    print(i)
                print("余额还有%s" % (money))
                print("欢迎下次光临！")
                break
        else:
            print("选择菜品编号错误，请重新输入！")

